//
//  BLUIView + Frame.swift
//  BLLiveTelecast
//
//  Created by BigL055 on 16/6/20.
//  Copyright © 2016年 bigL.liveTelecast.com. All rights reserved.
//

// MARK: - 设置ViewFarme相关属性
extension UIView{
    
    /// view上边的Y值
    func bl_top() -> CGFloat {
        return frame.origin.y
    }
    
    func bl_setTop(y : CGFloat) {
        var frameCopy = frame
        frameCopy.origin.y = y
        frame = frameCopy
    }
    
    /// view左边的X值
    func bl_left() -> CGFloat {
        return frame.origin.x
    }
    
    func bl_setLeft(x : CGFloat) {
        var frameCopy = frame
        frameCopy.origin.x = x
        frame = frameCopy
    }
    
    /// view右边的X值
    func bl_right() -> CGFloat {
        return frame.origin.x + frame.size.width
    }
    
    func blSetRight(right : CGFloat) {
        var frameCopy = frame
        frameCopy.origin.x = right - frame.size.width
        frame = frameCopy
    }
    
    /// view下边的Y值
    func bl_bottom() -> CGFloat {
        return self.frame.origin.y + self.frame.size.height
    }
    
    func bl_setBottom(bottom : CGFloat) {
        var frameCopy = frame
        frameCopy.origin.y = bottom - frame.size.height
        frame = frameCopy
    }
    
    /// view的宽度
    func bl_width() -> CGFloat {
        return self.frame.size.width;
    }
    
    func bl_setWidth(width : CGFloat) {
        var frameCopy = frame
        frameCopy.size.width = width
        frame = frameCopy
    }
    
    /// view的高度
    func bl_height() -> CGFloat {
        return self.frame.size.width;
    }
    
    func bl_setHeight(height : CGFloat) {
        var frameCopy = frame
        frameCopy.size.height = height
        frame = frameCopy
    }
    
    /// view中心X值
    func bl_centerX() -> CGFloat {
        return self.center.x
    }
    
    func bl_setCenterX(centerX : CGFloat) {
        self.center = CGPoint(x: centerX, y: self.center.y)
    }
    
    /// view中心Y值
    func bl_centerY() -> CGFloat {
        return self.center.y
    }
    
    func bl_setCenterY(centerY : CGFloat) {
        self.center = CGPoint(x: self.center.y, y: centerY)
    }

    
    /// view的origin
    func bl_origin() -> CGPoint {
        return self.frame.origin
    }
    
    func bl_setOrigin(origin : CGPoint) {
        var frameCopy = frame
        frameCopy.origin = origin
        frame = frameCopy
    }
    
    
    /// view的size
    func bl_size() -> CGSize {
        return self.frame.size
    }
    
    func bl_setSize(size : CGSize) {
        var frameCopy = frame
        frameCopy.size = size
        frame = frameCopy
    }

}